package cn.bdqn.service.impl;

import cn.bdqn.mapper.ItripAreaDicMapper;
import cn.bdqn.mapper.ItripHotelMapper;
import cn.bdqn.mapper.ItripLabelDicMapper;
import cn.bdqn.pojo.ItripHotel;
import cn.bdqn.pojo.ItripLabelDic;
import cn.bdqn.service.HotelService;
import cn.bdqn.vo.ItripSearchDetailsHotelVO;
import cn.bdqn.vo.ItripSearchFacilitiesHotelVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class HotelServiceImpl implements HotelService {
    @Resource
    private ItripLabelDicMapper itripLabelDicMapper;

    @Resource
    private ItripAreaDicMapper itripAreaDicMapper;

    @Resource
    private ItripHotelMapper itripHotelMapper;
    @Override
    public List selectLabelAllMessage(Map map) {
        map.put("parentId",16);
        return itripLabelDicMapper.selectAllMessageByParId(map);
    }

    @Override
    public Integer getHotelCOmmentCountByHotelId(Map<String ,Object> map) throws Exception {
        return itripHotelMapper.getCommentCountByHotelId(map);
    }

    @Override
    public List selectAreaAllMessage(Map map) {
        map.put("isHot",1);
        return itripAreaDicMapper.selectAllMessageByHot(map);
    }

    @Override
    public List selectAreaByCityId(Map map) {
        map.put("trade",1);
        return itripAreaDicMapper.selectAllMessageByCityId(map);
    }

    @Override
    public List<ItripLabelDic> findHotelFeatureByHotelId(Long id) throws Exception {
        return itripHotelMapper.getHotelFeatureByHotelId(id);
    }

    @Override
    public List<ItripSearchDetailsHotelVO> getHotelDetails(Long id) throws Exception {
        List<ItripLabelDic> itripLabelDicList=this.findHotelFeatureByHotelId(id);
        ItripSearchDetailsHotelVO vo = new ItripSearchDetailsHotelVO();
        List<ItripSearchDetailsHotelVO> list = new ArrayList<ItripSearchDetailsHotelVO>();
        vo.setName("酒店介绍");
        vo.setDescription(this.findItripHotelById(id).getDetails());
        list.add(vo);
        for (ItripLabelDic itripLabelDic:itripLabelDicList) {
            ItripSearchDetailsHotelVO vo2 = new ItripSearchDetailsHotelVO();
            vo2.setName(itripLabelDic.getName());
            vo2.setDescription(itripLabelDic.getDescription());
            list.add(vo2);
        }
        return list;
    }

    @Override
    public ItripHotel findItripHotelById(@Param(value = "id") Long id) throws Exception {
        return itripHotelMapper.getItripHotelById(id);
    }

    @Override
    public ItripSearchFacilitiesHotelVO findItripHotelFacilitiesById(@Param(value = "id") Long id) throws Exception {
        return itripHotelMapper.getItripHotelFacilitiesById(id);
    }




}
